<?php
session_start();

$host="mysql-user.cse.msu.edu"; // Host name
$username="hewittry"; // Mysql username
$password="A39777266"; // Mysql password
$db_name="hewittry"; // Database name

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$id = $_REQUEST['id'];
$query = "SELECT Photo FROM VehicleForSale WHERE NonAdmins_AllUsers_LogonID = '" . $_SESSION['username'] . "' AND VehicleForSaleID = " . $id;
$result = mysql_query($query); 

if (mysql_num_rows($result))
{
	$row = mysql_fetch_assoc($result);
	$query = "DELETE FROM VehicleForSale WHERE VehicleForSaleID = " . $id;
	$result = mysql_query($query); 
	unlink("upload/" . $row['Photo']);

}

header("location:manageVehicles.php");

?>
